package com.taldh.design.patterns.statemachine.impl;

import java.util.HashMap;

/**
 * date 2020/6/4
 *
 * @author 袁小黑
 * @version 1.0.0
 **/

public class OrderStateManager {

    private static HashMap<OrderEventEnum, AbstractEventProcessor> map = new HashMap<>();

    static {
        map.put(OrderEventEnum.CREATE_EVENT, new CreateOrderEventProcessor());
        map.put(OrderEventEnum.PAY_EVENT, new PayEventProcessor());
    }

    public void handleEvent(final String orderId, OrderEventEnum orderEventEnum) {
        AbstractEventProcessor processor = map.get(orderEventEnum);
        processor.processEvent(orderId);
    }

}
